package com.example.everying.model.entity.user;

import cn.hutool.core.date.DateTime;
import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.math.BigDecimal;
import java.time.LocalDateTime;


@Data
@TableName("user_balance_transaction")
@ApiModel(value = "用户余额交易记录实体")
public class UserBalanceTransactionEntity {

    @TableId(type = IdType.AUTO)
    @ApiModelProperty(value = "主键ID")
    private Long id;

    @ApiModelProperty(value = "用户ID")
    private String userId;

    @NotBlank(message = "用户类型不能为空")
    @ApiModelProperty(value = "用户类型 1-用户 0-平台")
    private String userType;

    @NotBlank(message = "交易ID不能为空")
    @ApiModelProperty(value = "交易ID")
    private String txId;

    @ApiModelProperty(value = "变动金额（单位分）(正数入账/负数出账)")
    private BigDecimal changeAmount;

    @ApiModelProperty(value = "变动后余额")
    private BigDecimal balanceSnapshot;

    @NotBlank(message = "交易类型不能为空")
    @ApiModelProperty(value = "交易类型 0-用户充值 1-用户提现 2-用户支出 3-用户收入 4-平台支出 5-平台收入")
    private String txType;

    @NotBlank(message = "类型不能为空")
    @ApiModelProperty(value = "类型 0-用户预付款 1-用户收款 2-用户充值 3-用户提现 4-用户退款 5-用户取消申请退款 6-转账")
    private String type;

    @ApiModelProperty(value = "交易状态")
    private Integer txStatus;

    @ApiModelProperty(value = "备注信息")
    private String remark;

    @TableField(fill = FieldFill.INSERT)
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "创建时间")
    private LocalDateTime createTime = LocalDateTime.now();
}
